﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Compiler.CompilerLogic;
using Compiler.LabForms;
using Compiler.LabLogic;

namespace Compiler
{
    [Serializable] //beatch
    public class Lab
    {
        public CompiledProgram CompiledProgram;
        private LabModel _labModel;
        public List<string> Code = new List<string>(); 

        public string FileName;

        public string Surname;
        public string Name;
        public string Group;

        public bool TestComplete;
        public int TestCorrectAnswers = 0;
        public double TestCorrectPercentage = 0;

        public bool StaticComplete;
        public int StaticMistakes = 0;

        public bool LexicalComplete;
        public int LexicalMistakes = 0;

        public bool SyntaxComplete;
        public int SyntaxMistakes = 0;

        public bool GenerationComplete;
        public int GenerationMistakes = 0;

        public static long IdentifierId;
        public static long ConstantId;
        
        private static Lab _lab;

        public static Lab GetLab()
        {
            return _lab;
        }

        public void StoreLabModel(LabModel labModel)
        {
            _labModel = labModel;
        }

        public LabModel GetLabModel()
        {
            return _labModel;
        }

        public static void LoadLab(Lab lab)
        {
            _lab = lab;
        }

        public static void CreateNewLab()
        {
            _lab = new Lab();
        }

        private Lab() {}
    }

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(MainForm.GetMainForm());
        }
    }

    class Utils
    {
        public static void MixList<T>(IList<T> list)
        {
            var r = new Random();
            var mixedList = new SortedList<int, T>();
            foreach (var item in list)
            {
                mixedList.Add(r.Next(), item);
            }
            list.Clear();
            for (int i = 0; i < mixedList.Count; i++)
            {
                list.Add(mixedList.Values[i]);
            }
        }
    }
}
